package haizhi.fruitmall.pojo.view;

import haizhi.fruitmall.enumeration.ResultEnum;
import haizhi.fruitmall.exception.ResultException;
import lombok.Data;

/**
 * @Date: 2017/10/10 21:52
 * @Author: Richard Zane
 * @Detail:
 */

@Data
public class ResultView {

    private Integer code;

    private String hint;

    private Object data;

    public ResultView() {
        this.code = ResultEnum.SUCCESS.getCode();
        this.hint = ResultEnum.SUCCESS.getHint();
    }

    public ResultView(Object data){
        this.code = ResultEnum.SUCCESS.getCode();
        this.hint = ResultEnum.SUCCESS.getHint();
        this.data = data;
    }

    public ResultView(ResultException resultException){
        this.code = ResultEnum.FAILURE.getCode();
        this.hint = ResultEnum.FAILURE.getHint()+resultException.getMessage();
    }
}
